package com.justnow.offer;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @author justnow
 * Created on 2020-10-08
 * Description
 */
public class Tuhuyangche01 {
    public int workdays_between (int y1, int m1, int d1, int y2, int m2, int d2) {
        // write code here
        String start = String.valueOf(y1)+String.valueOf(m1) + String.valueOf(d1);
        String end = String.valueOf(y2)+String.valueOf(m2) + String.valueOf(d2);
        SimpleDateFormat df = new SimpleDateFormat("yyyyMMdd");
        Date starDate = null;
        Date endDate = null;
        try {
            starDate = df.parse(start);
            endDate  = df.parse(end);
        } catch (ParseException e) {
            e.printStackTrace();
        }

        int count = 0;
        while (starDate.before(endDate)) {
            if (starDate.getDay() != 6 && starDate.getDay() != 0) {
                count++;
            }
            starDate.setDate(starDate.getDay() + 1);
        }
        return count;
    }
}
